package com.lyx.moocmusic.api;


import com.lyx.lib_network.CommonOkHttpClient;
import com.lyx.lib_network.okhttp.listener.DisposeDataHandle;
import com.lyx.lib_network.okhttp.listener.DisposeDataListener;
import com.lyx.lib_network.okhttp.request.CommonRequest;
import com.lyx.lib_network.okhttp.request.RequestParams;
import com.lyx.moocmusic.model.discovery.BaseRecommandModel;
import com.lyx.moocmusic.model.discovery.BaseRecommandMoreModel;
import com.lyx.moocmusic.model.friend.BaseFriendModel;
import com.lyx.moocmusic.model.user.User;

/**
 * 请求中心
 */
public class RequestCenter {

    public static void getRequest(String url, RequestParams params, DisposeDataListener listener, Class<?> clazz) {
        CommonOkHttpClient.get(CommonRequest.createGetRequest(url, params), new DisposeDataHandle(listener, clazz));
    }

    public static void postRequest(String url, RequestParams params, DisposeDataListener listener, Class<?> clazz) {
        CommonOkHttpClient.post(CommonRequest.createPostRequest(url, params), new DisposeDataHandle(listener, clazz));
    }

    public static void requestRecommandData(DisposeDataListener listener) {
        RequestCenter.getRequest(HttpConstants.HOME_RECOMMEND, null, listener,
                BaseRecommandModel.class);
    }

    //
    public static void requestRecommandMore(DisposeDataListener listener) {
        RequestCenter.getRequest(HttpConstants.HOME_RECOMMEND_MORE, null, listener,
                BaseRecommandMoreModel.class);
    }

    public static void requestFriendData(DisposeDataListener listener) {
        RequestCenter.getRequest(HttpConstants.HOME_FRIEND, null, listener, BaseFriendModel.class);
    }

    /**
     * 用户登陆请求
     */
    public static void login(DisposeDataListener listener) {
        RequestParams params = new RequestParams();
        params.put("mb", "18734924592");
        params.put("pwd", "999999q");
        RequestCenter.getRequest(HttpConstants.LOGIN, params, listener, User.class);
    }

}
